package io.kiki.stack.http.feign.form.multipart;

import feign.codec.EncodeException;

/**
 * A byte array writer.
 *
 * @author Artem Labazin
 */
public class ByteArrayWriter extends AbstractWriter {

    @Override
    public boolean isApplicable(Object value) {
        return value instanceof byte[];
    }

    @Override
    protected void write(Output output, String key, Object value) throws EncodeException {
        writeFileMetadata(output, key, null, null);

        byte[] bytes = (byte[]) value;
        output.write(bytes);
    }
}
